<?php
/**
 * Projects functions and definitions
 *
 */

/*-----------------------------------------------------------------------------------*/
/*	Register Project post format.
/*-----------------------------------------------------------------------------------*/
add_action( 'init', 'service_posttype_init' );
if ( !function_exists( 'service_posttype_init' ) ) :
function service_posttype_init() {

	$service_labels = array(
		'name' => _x('Service', 'post type general name','dnt_protoss'),
		'singular_name' => _x('Service', 'post type singular name','dnt_protoss'),
		'add_new' => _x('Add New', 'Service','dnt_protoss'),
		'add_new_item' => __('Add New Service','dnt_protoss'),
		'edit_item' => __('Edit Service','dnt_protoss'),
		'new_item' => __('New Service','dnt_protoss'),
		'all_items' => __('All Service','dnt_protoss'),
		'view_item' => __('View Service','dnt_protoss'),
		'search_items' => __('Search Service','dnt_protoss'),
		'not_found' =>  __('No Service found','dnt_protoss'),
		'not_found_in_trash' => __('No Services found in Trash','dnt_protoss'), 
		'parent_item_colon' => '',
		'menu_name' => __('Service','dnt_protoss')

	);
	$service_args = array(
		'labels' => $service_labels,
		'public' => true,
		'publicly_queryable' => true,
		'show_ui' => true, 
		'show_in_menu' => true, 
		'query_var' => true,
		'rewrite' => true,
		'capability_type' => 'post',
		'has_archive' => true, 
		'hierarchical' => false,
		'menu_position' => 5,
		'supports' => array( 'title', 'editor','thumbnail' )
	); 
	register_post_type( 'service', $service_args );

 }
	

endif;


add_shortcode('service-list', 'argo_service_list_shortcode');
function argo_service_list_shortcode($attr) {
	$html = "<div class='row-fluid'><div id='gallery-0' class='carousel slide'> \n <div class='carousel-inner'>";
	
	$args = array('posts_per_page' => -1,
				  'post_type'            => 'service',
				);
	$the_query = new WP_Query( $args );
	if($the_query->have_posts()) :
		$i = 0;
		while ( $the_query->have_posts() ) : $the_query->the_post();
			$active = ($i==0)?'active':'';
			$html .= "<div class='span4'>";
			$html .= get_the_post_thumbnail(get_the_ID(), 'medium');
			$html .= "<h3>".get_the_title()."</h3>";
			$html .= "<p>".get_the_excerpt()."</p>";
			$html .= "<p><a class='readmore' href='".get_permalink()."'>".__('Read more', 'argo')."</a></p>";
			$html .= "</div>";
			$i++;
		endwhile;
	endif;
	
	$html .= "
		</div>\n
		<a class='left carousel-control' href='#gallery-0' data-slide='prev'>".__('Prev', 'argo')."</a>\n
	    <a class='right carousel-control' href='#gallery-0' data-slide='next'>".__('Next', 'argo')."</a>
		</div>\n</div>\n";
	return $html;
}